
from rest_framework import serializers
from goods.models import SKUImage, SKU

#图片的增删改查
class SKUSimpleSerializer(serializers.ModelSerializer):

    class Meta:
        model = SKU
        fields = [
            'id',
            'name'
        ]

class ImageModelSerializer(serializers.ModelSerializer):

    class Meta:
        model = SKUImage
        fields = [
            'id',
            'sku',
            'image'   # ImageField类型字段序列化的结果就是image.url的结果，也就是存储后端url()函数返回的结果
        ]